package com.loveprogrammer.eternity.skill.support.states;

import com.loveprogrammer.eternity.model.Character;
import com.loveprogrammer.eternity.model.console.ConsolePrint;

import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;

/**
 * @version 1.0.0
 * @description: 恢复状态
 * @author: eric
 * @date: 2022-12-19 16:45
 **/
public class TreatmentState extends AbstractPositiveState{

    private int increaseHp;

    public TreatmentState(Character character, List<? extends Character> camp, int increaseHp) {
        super(character,camp);
        this.increaseHp = increaseHp;
    }

    @Override
    public int id() {
        return 20;
    }

    @Override
    public String name() {
        return "治疗";
    }

    @Override
    public String desc() {
        return "治疗，每秒钟加血";
    }

    @Override
    public void doReset() {

    }

    @Override
    public int counterId() {
        return 89;
    }

    @Override
    public void run() {
        // 如果已经死了就算了
        if(this.getCharacter().checkDead()){
            return;
        }
        if(getCharacter().hp().addAndGet(increaseHp) > getCharacter().getHpMax()){
            getCharacter().setHp(new AtomicInteger(getCharacter().getHpMax()));
        }
//        ConsolePrint.publishMessage(string + getCharacter().getName() + "(" + getCharacter().getCurrentHp() + "/" +
//                getCharacter().getHpMax() + ")" + "增加生命值：" + increaseHp);
    }
}
